@echo off
echo ========================================
echo WMS Simple 打包脚本
echo ========================================

echo 正在检查Python环境...
python --version
if %errorlevel% neq 0 (
    echo 错误: 未找到Python环境
    pause
    exit /b 1
)

echo 正在安装依赖包...
pip install -r requirements.txt
if %errorlevel% neq 0 (
    echo 错误: 依赖包安装失败
    pause
    exit /b 1
)

echo 正在清理旧的构建文件...
if exist "dist" rmdir /s /q "dist"
if exist "build" rmdir /s /q "build"
if exist "*.spec" del "*.spec"

echo 正在使用PyInstaller打包...
pyinstaller --onefile ^
    --windowed ^
    --name "WMSSimple" ^
    --icon=icon.ico ^
    --add-data "config.json;." ^
    --hidden-import "tkinter" ^
    --hidden-import "tkinter.ttk" ^
    --hidden-import "requests" ^
    --hidden-import "fastapi" ^
    --hidden-import "uvicorn" ^
    --hidden-import "sqlalchemy" ^
    --hidden-import "pydantic" ^
    main.py

if %errorlevel% neq 0 (
    echo 错误: 打包失败
    pause
    exit /b 1
)

echo 正在创建发布目录...
if not exist "release" mkdir "release"
copy "dist\WMSSimple.exe" "release\"
copy "README.md" "release\" 2>nul
copy "config.json" "release\" 2>nul

echo ========================================
echo 打包完成!
echo 可执行文件位置: release\WMSSimple.exe
echo ========================================
pause 